home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr26 / netprog.zip / NETPROG.TAR / ping / defs.h < prev    next >
C/C++ Source or Header  |  1989-12-17  |  2KB  |  72 lines

  1. /*
  2.  * Includes, defines and global variables used between functions.
  3.  */
  4.  
  5. #include <stdio.h>
  6. #include <errno.h>
  7. extern int    errno;
  8.  
  9. #include <sys/time.h>
  10. #include <sys/param.h>
  11. #include <sys/socket.h>
  12. #include <sys/file.h>
  13.  
  14. #include <netinet/in_systm.h>
  15. #include <netinet/in.h>
  16. #include <netinet/ip.h>
  17. #include <netinet/ip_icmp.h>
  18. #include <netdb.h>
  19.  
  20. #ifndef    INADDR_NONE
  21. #define    INADDR_NONE    0xffffffff    /* should be in <netinet/in.h> */
  22. #endif
  23.  
  24. #define    MAXWAIT          10    /* max time to wait for response, sec. */
  25.                 /* used only for final receive */
  26.  
  27. /*
  28.  * Beware that the outgoing packet starts with the ICMP header and
  29.  * does not include the IP header (the kernel prepends that for us).
  30.  * But, the received packet includes the IP header.
  31.  */
  32.  
  33. #define    MAXPACKET    4096    /* max packet size */
  34.  
  35. #ifndef    MAXHOSTNAMELEN
  36. #define MAXHOSTNAMELEN      64    /* should be defined in <param.h> */
  37. #endif
  38.  
  39. #define    SIZE_ICMP_HDR       8    /* 8-byte ICMP header */
  40. #define    SIZE_TIME_DATA       8    /* then the BSD timeval struct (ICMP "data") */
  41. #define    DEF_DATALEN      56    /* default data area after ICMP header */
  42.  
  43. int        packsize;    /* size of ICMP packets to send */
  44.                    /* this includes the 8-byte ICMP header */
  45. int        datalen;    /* size of data after the ICMP header */
  46.                    /* may be 0 */
  47.                    /* if >= SIZE_TIME_DATA, timing is done */
  48.  
  49. int        verbose;    /* enables additional error messages */
  50.  
  51. u_char        sendpack[MAXPACKET];    /* the packet we send */
  52. u_char        recvpack[MAXPACKET];    /* the received packet */
  53.  
  54. struct sockaddr_in    dest;    /* who to ping */
  55. int            sockfd;    /* socket file descriptor */
  56.  
  57. char        *hostname;
  58. int        npackets;    /* max # of packets to send; 0 if no limit */
  59. int        ident;        /* our process ID, to identify ICMP packets */
  60. int        ntransmitted;    /* sequence # for outbound packets = #sent */
  61. int        nreceived;    /* # of packets we got back */
  62.  
  63. int        timing;        /* true if time-stamp in each packet */
  64. int        tmin;        /* min round-trip time */
  65. int        tmax;        /* max round-trip time */
  66. long        tsum;        /* sum of all round-trip times, for average */
  67.             /* above 3 times are in milliseconds */
  68.  
  69. char        *inet_ntoa();    /* BSD library routine */
  70. int        sig_finish();    /* our function to finish up and exit */
  71. int        sig_alarm();    /* our SIGALRM signal handler */
  72.